package flujosdecontrol;

public class ExceptionsThrow{
	public int calculateFactorial(int n) throws Exception{
	  if (n < 0)
		throw new Exception("n must be positive");
	  if (n >= 60)
		throw new Exception("n must be < 60");
		
	  int fact = 1; // this  will be the result
      for (int i = 1; i <= n; i++) {
        fact *= i;
      }
      return fact;
	}
	
	public int testCalculateFactorial(){
		try{
			return calculateFactorial(-5);
		}catch(Exception ex){
			ex.printStackTrace();
		}
		return 0;
	}
	
	public static void main(String[] args){
		ExceptionsThrow obj = new ExceptionsThrow();
		obj.testCalculateFactorial();
	}
}